const {useTransaction, pool} = require("../../js/service/mysqlService.js");
const normalResult = require("../../js/normalResult.js");
const config = require("../../js/config.js");
const {baseModel} = require("../../js/service/baseModel");
const ManageBaseController = require("./manageBaseController");
let result = JSON.parse(normalResult)

module.exports = new (class Example02Controller extends ManageBaseController {
    constructor() {
        super();
        console.log("Example02Controller->constructor")
    }

    // http://localhost:9024/manage/example2/getAll
    async getAll(request, response) {
        let sql = 'select id,name,price from mo_goods order by id desc limit 4';
        let res = await baseModel.getAll(sql)
        return response.showResult(res)
    }

    // http://localhost:9024/manage/example2/getDataById?id=70
    async getDataById(request, response) {
        let {id} = request.query;
        let sql = 'select id, name, price from mo_goods';
        let res = await baseModel.getDataById(sql, id)
        return response.showResult(res)
    }
})
